package org.abc.manager 
{
	import flash.display.Sprite;
	import flash.external.ExternalInterface;
	import flash.ui.ContextMenu;
	import flash.ui.ContextMenuItem;

	/**
	 * 版本控制
	 * 单例模式类
	 * @author Mr.zheng
	 */
	public class VersionManager
	{
		private static var _instance:VersionManager = null;
		public function VersionManager(single:Single) 
		{
			if(single == null)
			{
				throw new Error("Can't create instance , Single is Null!"); 
			}
		}
		/**
		 * 单例引用
		 */
		public static function get instance():VersionManager
		{
			if(_instance == null)
			{
				_instance = new VersionManager(new Single());
			}
			return _instance;
		}
		
		private var _gameRoot:Sprite;
		private var _vMsg:String = "版本 "; 
		
		//public=========================
		public function init(gameRoot:Sprite,vMsg:String):void {
			_gameRoot = gameRoot;
			_vMsg += vMsg;
			setVersion();
		}
		/**
		 * 查看是在本地(false)还是在线上(true)
		 */
		public function isInContainer():Boolean{
			if (ExternalInterface.available && ExternalInterface.objectID) {
				return true;
			}else{
				return false;
			}
		}
		//private==============================
		private function setVersion():void {
			var myContextMenu:ContextMenu = new ContextMenu();
			myContextMenu.hideBuiltInItems();
			var item:ContextMenuItem=new ContextMenuItem(_vMsg,false,false);  
			myContextMenu.customItems.push(item);
			_gameRoot.contextMenu = myContextMenu;
		}
	}
}
class Single{}